//
//  HZAboutProductViewController.m
//  MyDoctor
//
//  Created by 黑眼圈 on 16/5/5.
//  Copyright © 2016年 heiyan. All rights reserved.
//关于产品

#import "HZAboutProductViewController.h"

@interface HZAboutProductViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UIImageView *centerImage;
@property (nonatomic,strong) UIImageView *nameImage;

@property (nonatomic,weak) UILabel * messageLabel;
@property (nonatomic,weak) UILabel * versionLabel;
@end

@implementation HZAboutProductViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置并添加子控件
    [self setupUI];
    
}


#pragma mark -
#pragma mark    设置并添加子控件
-(void)setupUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UITableView *tableView = [[UITableView alloc]init];
    tableView.dataSource = self;
    tableView.delegate = self;
    [self.view addSubview:tableView];
    [tableView makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.trailing.equalTo(self.view);
    }];
   
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    UIView *headView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, 300)];
    tableView.tableHeaderView = headView;


    UIView *footView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, SCREENH-400)];
    tableView.tableFooterView = footView;
    
  
    
    UILabel *message = [[UILabel alloc]init];
    message.text = @"用户交流群:888888";
    message.textColor = [UIColor colorWithRed:32/255.0 green:185/255.0 blue:182/255.0 alpha:1];
    self.messageLabel = message;
    
    UILabel *version = [[UILabel alloc]init];
    version.text = @"version:1.4.0";
    version.textColor = [UIColor lightGrayColor];
    self.versionLabel = version;

  
    self.centerImage =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_img_logo_nor.png"]];
    
    
    self.nameImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    
    // 添加控件
    [headView addSubview:self.centerImage];
    [headView addSubview:self.messageLabel];
    [headView addSubview:self.versionLabel];
    [headView addSubview:self.nameImage];

//    设置约束
    
   [self.centerImage makeConstraints:^(MASConstraintMaker *make) {
       make.centerX.equalTo(headView);
       make.top.equalTo(headView).offset(60);
       make.height.equalTo(80);
      
       
   }];
    
    [self.nameImage makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(headView);
        make.top.equalTo(self.centerImage.bottom).offset(20);
        make.height.equalTo(40);
        
        
    }];

    [self.messageLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(footView);
        make.bottom.equalTo(footView.bottom).offset(-60);

        make.height.equalTo(20);

        
    }];

    [self.versionLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.messageLabel.bottom).offset(15);
        make.height.equalTo(20);
        make.centerX.equalTo(footView);
    }];
    
    
}


#pragma mark -
#pragma mark     tableView数据源方法

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = @"用户协议";
    cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}


#pragma mark -
#pragma mark     tableView代理方法


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   
   
    UIWebView *web = [[UIWebView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    NSURL *url = [NSURL URLWithString:@"https://www.baidu.com"];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    HZBaseViewController *con = [[HZBaseViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:con];
    
    
    [self.navigationController pushViewController:con animated:YES];
  
    [SVProgressHUD show];
    [con.view addSubview:web];
    

    [SVProgressHUD dismissWithDelay:0.7];
    [web loadRequest:request];

    
    
    
}











@end
